<%@ taglib prefix="from" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>

    $(function () {
        var clinicIndexId = $("#id").val();
        if (clinicIndexId != null && clinicIndexId != "") {
            selectDoctor($("#deptId").val());
        }
    })
    /**
     *  根据科室Id加载医生
     * @param deptId
     */

    function selectDoctor(deptId) {
        $("#doctorInCharge").find("option").remove();
        $.ajax({
            type: "POST",
            url: '${ctx}/sys/orgGroupVsDept/findUserByDeptId?deptId=' + deptId,
            dataType: "json",
            success: function (data) {

                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        var user =data[i];
                        $("#doctorInCharge").append('<option value="' + user.id + '">' + user.name + '</option>');
//                        if(user.id==doctorId) {
////                            var obj=$("#selectId").find("option[value="+doctorId+"]");
//                            $("#doctorInCharge").val(doctorId).trigger("change");
//                        }
                    }

                } else {
                    $("#doctorInCharge").find("option").remove();
                    $("#doctorInCharge").append('<option value="">请选择</option>');
                }
            },
            error: function (data) {
                toastr.error('网络连接错误,请检查网络');
            }
        });
    }
</script>
<section class="panel">
    <div class="panel-body">
        <form id="inputForm" class="form-horizontal" modelAttribute="clinicIndex"
              onsubmit="return formSaveLoad('mainCenterDiv','inputForm','${ctx}/doctor/liveRequisition/save','${ctx}/doctor/liveRequisition/index');">
                <input type="hidden" path="visitNo" value="${patVisit.id}"/>
            <div class="form-group">
                <label class="col-sm-2 control-label">患者姓名：</label>
                <div class="col-sm-2">
                    <input  name="name" value="${patVisit.patVisitIndex.name}" data-parsley-validate="true" htmlEscape="false" class="form-control"  maxlength="40" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">性别：</label>
                <div class="col-sm-2">
                    <sys:select checkValue="${fns:getDictLabels(patVisit.patVisitIndex.sex, 'SEX_DICT', '')}" lists="${fns:getDictList('SEX_DICT')}" className="form-control" name="sex"></sys:select>
                </div>
            </div>

            <div class="form-group">
            <label class="col-sm-2 control-label">年龄：</label>
            <div class="col-sm-2">
                <input  name="age" data-parsley-validate="true" value="${patVisit.patVisitIndex.age}" htmlEscape="false" class="form-control"  maxlength="40" />
             </div>
            </div>

            <div class="form-group" >
                <label class="col-sm-2 control-label">身份证号：</label>
                <div class="col-sm-2">
                    <input name="idNo" value="${patVisit.patVisitIndex.idNo}" data-parsley-validate="true" htmlEscape="false" class="form-control"  maxlength="40" />
                </div>
            </div>

            <div class="form-group" >
                <label class="col-sm-2 control-label">入院科室：</label>
                <div class="col-sm-2">
                    <sys:treeselect selectedParent="true" isnull="true" id="orgDeptId"  name="deptAdmissionTo"  value="${liveRequisition.hospitalizedDept}"  update="false" labelName="${liveRequisition.hospitalizedDept}" labelValue="${fns:getDeptName(liveRequisition.hospitalizedDept,'')}"
                                    title="科室" url="/sys/orgDept/treeData" extId="${orgDept.id}" cssClass="form-control" />
                </div>
                <input type="hidden" id="deptId" value="${orgDept.deptId}">
                <label class="col-sm-2 control-label">入院病区：</label>
                <div class="col-sm-2">
                    <sys:treeselect selectedParent="true" method="selectDoctor" id="wardAdmissionTo" name="wardAdmissionTo"
                                    value="${liveRequisition.hospitalizedDept}"
                                    update="false"
                                    labelName="${clinicItemDict.orgDept.deptName}"
                                    labelValue="${clinicItemDict.orgDept.deptName}"
                                    title="科室" url="/sys/orgDept/treeData?clinicAttrs=2" isnull="true"
                                    extId="${orgDept.id}" cssClass="form-control" />
                </div>
            </div>

            <div class="form-group" >
                <label class="col-sm-2 control-label">入院时间：</label>
                <div class="col-sm-2">
                    <input name="admissionDate" data-parsley-required="true" value="<fmt:formatDate value="${patVisit.admissionDate}" pattern="yyyy-MM-dd" type="date" dateStyle="long" />" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control Wdate"/>
                </div>
            </div>

            <div class="form-group" >
            <label class="col-sm-2 control-label">患者费别：</label>
            <div class="col-sm-2">

                <sys:select checkValue="${patVisit.patVisitIndex.chargeType}" lists="${fns:getDictList('CHARGE_TYPE_DICT')}" className="form-control" name="chargeType"></sys:select>
            </div>
            </div>

            <div class="form-group" >
            <label class="col-sm-2 control-label">出生地：</label>
            <div class="col-sm-2">
                <input name="homeplace" value="${patVisit.patVisitIndex.homeplace}" data-parsley-validate="true" htmlEscape="false" class="form-control"  maxlength="40" />
            </div>
            </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input id="btnSubmit" class="btn btn-primary"  type="submit" value="保 存">&nbsp;
                        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('mainCenterDiv','${ctx}/doctor/liveRequisition/hospitalRegistr')">
                    </div>
                </div>

        </form>
    </div>
</section>
